package cn.itsource.controller;

import cn.itsource.basic.aop.LogAop;
import cn.itsource.basic.domain.AjaxResult;
import cn.itsource.basic.util.PageList;
import cn.itsource.domain.org.Employee;
import cn.itsource.service.EmployeeService;
import cn.itsource.vo.EmplQuery;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("empl")
public class EmployeeController {
    @Autowired
    EmployeeService employeeService;

    /**
     * 分页查询
     * @return
     */
    @LogAop
    @PostMapping("/findPage")
    public PageList<Employee> findPage(@RequestBody EmplQuery baseQuery){
        return employeeService.findPage(baseQuery);
    }
        /**
        * 1.请求url:.empl/add
        * 2.请求方式;post
        * 3.请求参数 :employee
        * 4.PageList
        */
    @LogAop
    @PostMapping("/add")
    public AjaxResult add(@RequestBody Employee employee){
        //todo 首先需要获取到当前新增员工的门店id,但是我们这边还没有做登录先模拟写死一个
        employee.setShopId(999L);
        return employeeService.insert(employee);
    }

    @GetMapping("/test")
    public AjaxResult test(){
        Employee employee = new Employee();
        employee.init();
        employee.setUsername("zs");
        return employeeService.test(employee);
    }
}
